package cn.lds.j375.chlm.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultDTO<T> {

    private Integer code;

    private String msg;

    private T data;

    /**
     * 执行成功，不封装数据
     * @return
     */
    public static ResultDTO buildSuccess(){
        return new ResultDTO(ChlmConstant.SUCCESS_CODE,ChlmConstant.SUCCESS_MSG,null);
    }

    public static ResultDTO buildSuccess(Object data){
        return new ResultDTO(ChlmConstant.SUCCESS_CODE,ChlmConstant.SUCCESS_MSG,data);
    }

    public static ResultDTO buildError(){
        return new ResultDTO(ChlmConstant.ERROR_CODE,ChlmConstant.ERROR_MSG,null);
    }
    public static ResultDTO buildError(String msg){
        return new ResultDTO(ChlmConstant.ERROR_CODE,msg,null);
    }


}
